package com.probiz.estore.common.model.customer;

import org.apache.commons.lang.StringUtils;

import com.probiz.estore.common.model.customer.base.ConsultTbl;

/**
 * Model class for Consult. Add not database mapped fileds in this class.
 */
public class Consult extends ConsultTbl {
	
	/*
	 * MY_CONSULT_LIST - 我发表的咨询列表
	 */
	public static enum FilterHqlName{MY_CONSULT_LIST};
	
	public static Short STATUS_READ = (short)1; //已读
	public static Short STATUS_UNREAD = (short)0; //未读
	public static Short STATUS_SHOW = (short)1; //显示
	public static Short STATUS_UNSHOW = (short)0; //隐藏
	public static Integer STATUS_TOP = 0; //置顶
	public static Integer STATUS_UNTOP = 10; //非置顶
	
	//咨询资格 0=匿名 1=登录用户
	public static Short		CONSULT_RIGHT_ANONYMOUS		= (short) 0;	
	public static Short		CONSULT_RIGHT_LOGIN		= (short) 1;	
  	/**
  	 * 获得咨询人或者回复人名称
  	 * @return
  	 */
  	public String getConsultUserName(){
		if(null != customer){
			return customer.getFullName();
		}else{
			return customerName;
		}
	}
  	
  	/**
	 * 获得咨询人地域地理位置
	 * @return
	 */
	public String getConsultUserArea(){
		String area = "";
		if (StringUtils.isNotBlank(this.getAddress())) {
			String[] addresses = this.getAddress().split(" ");
			area = addresses[0];
		}
		return area;
	}

  	/**
	 * Default Empty Constructor for class Consult
	 */
	public Consult () {
		super();
	}
	
	/**
	 * 定义实体的业务名取值； consultName
	 * 必须手工完成这个部分，否则编译不通过。
	 */
	public String getConsultName () {
		if (consultId == null)
	        return "";
	    else
			//返回一个指定有业务意义的属性值;
			//如：product的VO就用product.productName
	        return this.subject;
	}
	
	/**
	 * Default Key Fields Constructor for class Consult
	 */
	public Consult (
		 Integer in_consultId
		) {
		super (
		  in_consultId
		);
	}

}
